{  Statement: http://acmp.ru/?main=task&id_task=17
   Verdict: Accepted
}
uses
  SysUtils, Math;

var
  i,n,ans,cur,cc:longint;
  a,b:array[0..30010] of longint;
  
begin
reset(input,'input.txt');
rewrite(output,'output.txt');
read(n);
cc := 0;
for i:=1 to n do begin
  read(a[i]);
  if a[i] = a[1] then begin
    inc(cc);
    b[cc] := i;
  end;
end;
ans := 1;
i := 1;
cur := 1;
while i < n do begin
  inc(i);
  if a[i] <> a[i - ans] then begin
    inc(cur);
    ans := b[cur] - 1;
    i := b[cur];
  end;
end;
write(ans);
end.
